#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/5/16 11:05
# @Author  : Leixu
# @Site    : 
# @File    : task.py
# @Software: PyCharm Community Edition
from __future__ import absolute_import

from luobo.component.celery_c.celery1 import app


@app.task(name='task.tornado_http_client', serializer='pickle')
def tornado_http_client(url, config):
    pass


@app.task(name='task.remote_script', serializer='pickle')
def remote_script(rules, param_deliver, active_rule, crawler_config):
    pass


@app.task(name="task.add")
def add(x, y):
    return {'the value is ': str(x + y)}


@app.task
def writefile():
    out = open('/tmp/data.txt', 'w')
    out.write('hello' + '\n')
    out.close()


@app.task
def mul(x, y):
    return x * y


@app.task
def xsum(numbers):
    return sum(numbers)


if __name__ == "__main__":
    res = add.apply_async(args=[122, 34], queue='machine4', routing_key='machine4')
    print(res.get())
